#ifndef __DEBUG_H__
#define __DEBUG_H__
#ifdef DEBUG
#include <iostream>
#include <cstdio>
#include <string>
#include <stdlib.h>
//assert : exit if fail
#define ASSERT(X)     if (!(X)) {printf("\n %s: assertion failed at line %d\n",__FILE__,__LINE__);exit(0);} 
#define PRINT(fmt, args...) printf("%s:%s:%d: "fmt, __FILE__, __FUNCTION__, __LINE__, args); 
#define PVAR(var) std::cout<<__FILE__<<":"<<__FUNCTION__<<":"<<__LINE__<<":    "<<#var<<" = "<<var<<std::endl;
#define PLINE(array,n) \
printf("\n%s:%s:line %d : "#array"[0:%d]=\n",__FILE__, __FUNCTION__, __LINE__,n);\
for(register size_t __i__=0;__i__<n;__i__++) \
    std::cout<<__i__<<" ";\
std::cout<<std::endl;\
for(register size_t __i__=0;__i__<n;__i__++) \
        std::cout<<array[__i__]<<" ";\
        std::cout<<std::endl;
#define PMAP(array,n,m,fmt) {\
printf("%s:%s:line %d : "#array"[0:%d][0:%d]=\n",__FILE__, __FUNCTION__, __LINE__,n,m);\
std::cout<<"  ";\
for(register size_t __j__=0;__j__<m;__j__++) \
std::cout<<__j__;\
std::cout<<std::endl;\
for(register size_t __i__=0;__i__<n;__i__++) {\
    std::cout<<__i__;\
    for(register size_t __j__=0;__j__<m;__j__++) \
        printf(fmt,array[__i__][__j__]);\
    std::cout<<std::endl;\
}\
}
#define PBIN(n) {\
        int i,bit[256];\
        for(i=0;i<sizeof(n)*8;i++) {bit[i]=n%2;n>>=1;}\
        for(;i>0;i--) {std::cout<<bit[i-1];}\
    }
#define EVAL(cmd) cmd
#else
#define PMAP(array,n,m,fmt) 
#define ASSERT(X)
#define PVAR(var)
#define PRINT(fmt, args...) 
#define PLINE(array,n)
#define PBIN(n)
#define EVAL(cmd)
#endif


#endif /* __DEBUG_H__ */

